<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>设备</title>
    <meta name="keywords" content="设备">
    <meta name="description" content="设备">

    <link rel="shortcut icon" href="favicon.ico">
    <link href="<?= base_url('assets/css/bootstrap.min.css?v=3.3.6') ?>" rel="stylesheet">
    <link href="<?= base_url('assets/css/font-awesome.css?v=4.4.0') ?>" rel="stylesheet">

    <!-- Data Tables -->
    <link href="<?= base_url('assets/css/plugins/dataTables/dataTables.bootstrap.css') ?>" rel="stylesheet">

    <link href="<?= base_url('assets/css/animate.css') ?>" rel="stylesheet">
    <link href="<?= base_url('assets/css/style.css?v=4.1.0') ?>" rel="stylesheet">

</head>


<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">

    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>
                        <small>修改用户密码</small>
                    </h5>
                    <div class="ibox-tools">


                        <!--                            <ul class="dropdown-menu dropdown-user">-->
                        <!--                                <li><a href="table_data_tables.html#">选项1</a>-->
                        <!--                                </li>-->
                        <!--                                <li><a href="table_data_tables.html#">选项2</a>-->
                        <!--                                </li>-->
                        <!--                            </ul>-->

                    </div>
                </div>
                <div class="ibox-content">


                    <form class="form-horizontal m-t" id="user_form" >
                        <div class="form-group">
                            <label class="col-sm-3 control-label">用户：</label>

                            <div class="col-sm-8">
                                <input type="text" placeholder="用户" class="form-control" disabled value="<?= $this->session -> userdata('loginname') ?>">
                            </div>
                        </div>


                        <div class="form-group">
                            <label class="col-sm-3 control-label">旧密码：</label>

                            <div class="col-sm-8">
                                <input type="password" placeholder="密码" class="form-control" id="old_password" name="old_password">
                            </div>
                        </div>


                        <div class="form-group">
                            <label class="col-sm-3 control-label">新密码：</label>

                            <div class="col-sm-8">
                                <input type="password" placeholder="密码" class="form-control" id="new_password" name="new_password">
                            </div>
                        </div>


                        <div class="form-group">
                            <label class="col-sm-3 control-label">确认信密码：</label>

                            <div class="col-sm-8">
                                <input type="password" placeholder="密码" class="form-control" id="confirm_password" name="confirm_password"
                                       >
                            </div>
                        </div>


                        <div class="form-group">
                            <div class="col-sm-offset-3 col-sm-8">
                                <button class="btn btn-sm btn-white" type="submit">保存</button>
                            </div>
                        </div>
                    </form>


                </div>
            </div>
        </div>
    </div>

</div>


<!-- 全局js -->


<?php include "include/admin_foot_script.php" ?>

<!-- Data Tables -->
<script src="<?= base_url('assets/js/plugins/dataTables/jquery.dataTables.js') ?>"></script>
<script src="<?= base_url('assets/js/plugins/dataTables/dataTables.bootstrap.js') ?>"></script>
<link href="<?= base_url('assets/css/style.css?v=4.1.0') ?>" rel="stylesheet">
<!-- 自定义js -->
<script src="<?= base_url('assets/js/content.js?v=1.0.0') ?>"></script>


<!-- Page-Level Scripts -->
<script>

    $(document).ready(function () {

        // validate signup form on keyup and submit
        var icon = "<i class='fa fa-times-circle'></i> ";

        $("#user_form").validate({
            rules: {
                old_password: "required",

                new_password: {
                    required: true,
                    minlength: 6
                },

                confirm_password: {
                    required: true,
                    minlength: 6,
                    equalTo: "#new_password"
                }

            },
            messages: {
                old_password: icon + "请输入旧密码",
                new_password: {
                    required: icon + "请输入您的密码",
                    minlength: icon + "密码必须6个字符以上"
                },
                confirm_password: {
                    required: icon + "请再次确认密码",
                    minlength: icon + "密码必须6个字符以上",
                    equalTo: icon + "两次输入的密码不一致"
                }
            },

            submitHandler: function (form) {
                var submitData = {
                    "old_pwd": $("#old_password").val(),
                    "new_pwd": $("#new_password").val()
                };

                $.post("<?= base_url('admin/user/password') ?>", submitData, function (res) {
                    if (res.code == 200) {
                        toastr.success("操作成功", '提示');
                    } else {
                        toastr.error(res.msg, '提示');
                    }

                }, "json");

            }


        });


    });


</script>


</body>

</html>
